package  
{
	import org.flixel.*;

	public class Player extends GameObject
	{
		[Embed(source = "../data/player.png")] private var ImgPlayer:Class;

		protected var sword: Sword;

		public function Player(X:Number, Y:Number, Z: Number = 0)
		{
			super(X, Y, Z);
			loadGraphic(ImgPlayer, false, true);
			offset.x = 7;
			offset.y = 1;
			width = 12;
			height = 18;
			
			sword = new Sword(this);
		}

		public function getSword():Sword { return sword; }
		
		override public function update():void 
		{
			super.update();
			if (FlxG.keys.W) y -= 1;
			if (FlxG.keys.S) y += 1;
			if (FlxG.keys.A) x -= 1;
			if (FlxG.keys.D) x += 1;
			if (FlxG.mouse.justPressed())
			{
				sword.shoot(angle - 90);
			}
		}
	}
}